using ExampleWebApplication.Entities;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace ExampleWebApplication.Infraestruture.NHibernate.EntityMappings
{
    public class CategoryMap : ClassMapping<Category>
    {
        public CategoryMap()
        {
            Table("Categories");
            Id(x => x.CategoryID, map => { map.Generator(Generators.Identity); map.Column("CategoryID"); });
            Property(x => x.CategoryName, map => { map.Column("CategoryName"); map.NotNullable(true); map.Length(15); });
            Property(x => x.Description, map => { map.Column("Description"); map.Length(1073741823); });
            Property(x => x.Picture, map => { map.Column("Picture"); map.Length(2147483647); });
            Bag(x => x.Products, map => { map.Inverse(true); map.Key(key => key.Column("CategoryID")); }, rel => rel.OneToMany());
        }
    }
}
